<?php
define('path', dirname(__FILE__));
$libs = path .'/libs/';

include_once $libs.'cls_mysql.php';

$config = include '../Runtime/Conf/config.php';
include $libs.'ImgModel.class.php';
$model_img = new ImgModel();
$db = new cls_mysql($config['db_host'], $config['db_user'], $config['db_pwd'], $config['db_name'],'utf8');
$sql = 'select count(*) from m_vod where Left(vod_pic,7)="http://" ';
$total = $db->getOne($sql);
$i= 0;
do{
	$sql = 'select vod_id ,vod_pic from m_vod where Left(vod_pic,7)="http://" order by vod_addtime desc limit 100';
	$list = $db->getAll($sql,'vod_id');
	
            foreach($list as $key=>$value){
                $i++;
                $imgnew = $model_img->down_img($value['vod_pic'],'vod',$config);
                if($value['vod_pic'] == $imgnew){
//                    $rs->where('vod_id='.$value['vod_id'])->setField('vod_pic',str_replace("http://","httpf://",$value['vod_pic']));
                    $newimgstr = str_replace("http://","httpf://",$value['vod_pic']);
                    $db->update('m_vod',array('vod_pic'=>$newimgstr),'vod_id='.$value['vod_id']);
                    echo $i." ".$value['vod_pic'].'下载失败!'."\n";
                }else{
                    $db->update('m_vod',array('vod_pic'=>$imgnew),'vod_id='.$value['vod_id']);
//                    $rs->where('vod_id = '.$value['vod_id'])->setField('vod_pic',$imgnew);
                    echo $i." ".$value['vod_pic'].'下载成功!'."\n";
                }
              
            }
}while($i<$total);
